﻿<!--
	========================================================================
	 awzBoxes Library
	
	 Homepage: http://www.awzhome.de/
	========================================================================
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of awzBoxes Library.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2011-2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	========================================================================
-->

<UserControl
	x:Class="AWZhome.awzBoxes.Box"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:box="clr-namespace:AWZhome.awzBoxes"
	xmlns:boxt="clr-namespace:AWZhome.awzBoxes.Tools"
	Focusable="False"
	AllowDrop="True"
	GotFocus="UserControl_GotFocus"
	MouseRightButtonUp="BoxItemTabControl_MouseRightButtonUp"
	mc:Ignorable="d" 
	d:DesignHeight="300" d:DesignWidth="300">

	<UserControl.CommandBindings>
		<CommandBinding
			Command="box:BoxCommands.BoxItemClose"
			CanExecute="BoxItemCloseCommandBinding_CanExecute"
			Executed="BoxItemCloseCommandBinding_Executed" />
		<CommandBinding
			Command="box:BoxCommands.BoxAutoHide"
			CanExecute="BoxAutoHideCommandBinding_CanExecute"
			Executed="BoxAutoHideCommandBinding_Executed" />
		<CommandBinding
			Command="box:BoxCommands.BoxItemFloating"
			CanExecute="BoxItemFloatingCommandBinding_CanExecute"
			Executed="BoxItemFloatingCommandBinding_Executed" />
	</UserControl.CommandBindings>

	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="Styles/BoxStyle.Generic.xaml"/>
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>

	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<!-- Definition of title bar (for side bars) -->
		<Label x:Name="BoxTitleLabel" Grid.Row="0" Style="{StaticResource SideBarTitleStyle}"
				 Visibility="{Binding Path=IsSideBar, Converter={StaticResource BooleanToVisibilityConverter}}"
				 Content="{Binding ElementName=BoxItemTabControl, Path=SelectedItem.Title}"
				 PreviewMouseLeftButtonDown="TabControl_PreviewMouseLeftButtonDown"
				 MouseMove="TabControl_MouseMove"
				 AllowDrop="True" />

		<!-- TabControl for sub-windows-->
		<TabControl Grid.Row="1" x:Name="BoxItemTabControl" ItemsSource="{Binding Items}"
						Visibility="Collapsed"
						PreviewMouseLeftButtonDown="TabControl_PreviewMouseLeftButtonDown"
						AllowDrop="True"
						Margin="0,0,0,0"
						MouseMove="TabControl_MouseMove"
						PreviewKeyUp="BoxItemTabControl_PreviewKeyUp"
						PreviewKeyDown="BoxItemTabControl_PreviewKeyDown"
						Focusable="False">
		</TabControl>

		<boxt:DragOverlayBox
			Grid.Row="1" x:Name="DragOverlayBox"
			Visibility="{Binding Path=IsOverlayedOnDragOver, Converter={StaticResource BooleanToVisibilityConverter}}" />
	</Grid>
</UserControl>
